/*
   Zii EGGxplorer - A simple Zii file browser

   Copyright (C) 2009 - 2010 Claudio Corti

   Header file for MainWindow class, derived from CSkinWindowMultiContainer; this is the browsing
   window.
*/

#ifndef _MAINWINDOW_H_
#define _MAINWINDOW_H_

// C++ standard library
#include <list>

// Plaszma library
#include <skin.h>

// Application headers
#include "PathInfo.h"
#include "Image.h"

using namespace std;
using namespace nZiiLABS;

// Custom class for main application window, derived from a multi window container
class MainWindow : public CSkinWindowMultiContainer
{
public:
   // Constructor
   MainWindow(CLayoutStudio *, CSkinApp *);

   // Handle SD notification
   void OnSDNotification(CUserEvent *);

   // Destructor
   ~MainWindow();

protected:
   // Called whenever a child widget is deleted
   void OnDeleteChildWidget(CSkinWidget *);

   // Called when the window is created
   void OnCreate();

   // Called when an item in the list is selected
   EventReturnType OnSelChange(CSkinWidget *);

   // Called when a toolbar button is clicked
   EventReturnType OnClick(CSkinWidget *);

private:
   CLayoutStudio    *layout_studio;      // Main layout Studio object
   CResource        *image_res;          // Image resources: a single image resource file
   Image           **images;             // Icons for various types of path
   Image           **denied_images;      // Icons for various types of path with denied access
   Image           **error_images;       // Icons for various types of path with error
   Image            *link_symbol;        // Icon for link file status
   Image            *denied_symbol;      // Icon for denied access  file status
   Image            *error_symbol;       // Icon for error file status
   CTwoLineListBox  *list_view;          // List box for list view mode
   CToolBar         *tool_bar;           // Tool bar

   PathInfo         *current_path;       // Current path shown in the browsing window
   list<PathInfo *>  folders;            // List of folders contained in current_path
   list<PathInfo *>  files;              // List of files contained in current_path
   SDCardInfo        sd_info;            // Structure with SD card informations

   CSkinApp         *app;                // Application instance

   int               display_state[3];   // Display state of the list view

   // Get a file image
   Image *get_image(int, int);

   // Create a link file image
   void create_link_image(int);

   // Create an error or denied file image
   void create_image(int, int);

   // Add a file to the list
   void add_file_to_list(PathInfo *);

   // Fill the listbox
   void show_list_view();

   // Fill folders and files list
   void browse_current_path();

   // Print the size of a file in B, KB, MB, GB, etc
   void get_pretty_size(int, char *);

   //Update the widgets according to the current path
   void UpdateWidgets();
};

#endif   /* _MAINWINDOW_H_ */
